package com.yh.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yh.javabean.Orders;
import com.yh.javabean.Product;
import com.yh.mapper.OrdersMapper;
import com.yh.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;

@Controller
@RequestMapping("/order")
public class OrdersController {
    @Autowired
    OrdersService ordersService;
    @GetMapping("/findAll")
    public String findAll(@RequestParam(value = "page", required = false, defaultValue = "1") int page,
                          @RequestParam(value = "size", required = false, defaultValue = "5") int size,
                          HttpServletRequest request){
        PageHelper.startPage(page, size);
        ArrayList<Orders> all = ordersService.findAll();
        PageInfo<Orders> pageInfo = new PageInfo<>(all);
        request.setAttribute("pageInfo", pageInfo);
        return "order/order-list";
    }


}